<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="./index.js"></script>
  <!-- <script>
    function p1 () {
      return new MyPromise(function (resolve, reject) {
        setTimeout(() => {
          // resolve('p1 resolve')
          reject('p1 reject')
        }, 3000);
      })
    }
    function p2 () {
      return new MyPromise(function (resolve, reject) {
        // resolve('p2 resolve')
        setTimeout(() => {
          reject('p2 reject')
        }, 2000);
      })
    }
    function p3 () {
      return new MyPromise(function (resolve, reject) {
        setTimeout(() => {
          // resolve('p3 resolve')
          reject('p3 reject')
        }, 1000);
      })
    }
    MyPromise.any([p1(), p3(), p2()]).then(result => {
      console.log('成功');
      console.log(result);
    }, reason => {
      console.log('失败');
      console.log(reason);
    })













    // function p1 () {
    //   return new Promise(function (resolve, reject) {
    //     console.log('p3');
    //     setTimeout(() => {
    //       console.log('p1');
    //       resolve('p1')
    //     }, 1000);
    //   })
    // }
    // function p2 () {
    //   return new Promise(function (resolve, reject) {
    //     console.log('p2');
    //     resolve('p2')
    //   })
    // }
    // p1()
    // p2() 先打印p2 两秒后打印p1

    // Promise.all([p1(), p2()]).then(function (result) {
    //   console.log(result);
    // })





    // var promise = new Promise((resolve, reject) => {
    //   resolve(100)
    // })
    // let p1 = promise.then((value) => {
    //   console.log(value);
    //   return p1
    // })
    // p1.then(() => { }, (reason) => {
    //   console.log(reason.message);
    // })
    // promise.then().then().then((value) => console.log(value))
  </script> -->
</body>

</html>